package com.fire.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fire.dao.TestDao;
import com.fire.service.TestService;
import com.fire.util.base.ResultBody;
import com.fire.util.base.TokenUtil;

@Service
public class TestServiceImpl implements TestService {

	@Autowired
	private TestDao testDao;

	@Override
	public ResultBody getUserName() throws Exception {
		ResultBody result = new ResultBody();
		String name = testDao.getName(1);
		result.setData(name);
		return result;
	}

	@Override
	public ResultBody getToken() throws Exception {
		ResultBody result = new ResultBody();
		// 创建token
		String token = TokenUtil.createJwt(1, System.currentTimeMillis() + 3600000);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("token", token);

		result.setData(map);
		return result;
	}

}
